<template>
  <div id='home'>
    <!-- 响应事件 -->
    <app-header :title='title' @titleChange='updateTitle($event)'></app-header>

    <users :users='users'></users>

    <app-footer :title='title'></app-footer>
  </div>
</template>

<script>
import Users from './Users'
import Header from './Header'
import Footer from './Footer'

export default {
  name: 'Home',
  components: {
    Users,
    'app-header': Header,
    'app-footer': Footer
  },
  methods: {
    updateTitle: function (title) {
      this.title = title
    }
  },
  data () {
    return {
      users: [
        // { name: 'Henry', position: 'Web开发', show: true },
        // { name: 'Bucky', position: 'Java开发', show: true },
        // { name: 'Luffy', position: '海贼王', show: true },
        // { name: 'Yaso', position: '风一样的男子', show: true },
        // { name: 'Yaso', position: '风一样的男子', show: true },
        // { name: 'Yaso', position: '风一样的男子', show: true },
        // { name: 'Yaso', position: '风一样的男子', show: true }
      ],
      title: '传值'
    }
  },
  created () {
    this.$http.get('http://jsonplaceholder.typicode.com/users')
      .then((data) => {
        // console.log(data)
        this.users = data.body
      })
  }
}
</script>

<style scoped>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center; */
  color: #2c3e50;
  /* margin-top: 60px; */
}
</style>
